-
-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onDelay
hook
#47
onDelay
hook
#47
Conversation
test.js
Outdated
t.is(delayedCounter, delayedExecutions); | ||
|
||
await Promise.all(promises); | ||
t.pass(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t.pass(); |
This is moot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
index.d.ts
Outdated
/** | ||
A callback for when a call gets delayed due to the number of calls in the `interval` exceeded the `limit`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | |
A callback for when a call gets delayed due to the number of calls in the `interval` exceeded the `limit`. | |
/** | |
Get notified when function calls are delayed due to exceeding the `limit` of allowed calls within a the given `interval`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
index.d.ts
Outdated
await throttled(); //=> Reached the interval limit, the call is delayed | ||
``` | ||
*/ | ||
readonly onDelay?: () => void | Promise<void>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readonly onDelay?: () => void | Promise<void>; | |
readonly onDelay?: () => void; |
It should not have Promise
here when it does not actually await the returned promise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, removed
Should be documented in the readme too. |
Added to the readme |
readme.md
Outdated
const throttle = pThrottle({ | ||
limit: 2, | ||
interval: 1000, | ||
onDelay: () => console.log('Reached the interval limit, the call is delayed'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the same as the one in index.d.ts (missing braces). Make sure they are both in sync.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Synced
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You synced it the wrong way.
The changes in ba5ef67 should be preserved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, fixed
Is it possible to get details of the request being made when the onDelay callback is triggered? |
We can add the arguments of the delayed call. Would that help? |
Hey @dormeiri - yes I think that should be good. Thanks |
Fixes #44